﻿using System;
using System.Collections.Generic;
using System.Data;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Lib.Utility;
using Module.BusinessLogic;

namespace Web.UserControls
{
    public partial class doithamgia : System.Web.UI.UserControl
    {       
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                int totalRecords;
                int cPage = 1;
                if (Request.QueryString.Get("cpage") != null)
                    cPage = ConvertUtility.ToInt32(Request.QueryString.Get("cPage"));
                int from = (cPage - 1) * 5 + 1;
                if (from == 0) from = 1;
                int to = (cPage) * 5;
                totalRecords = CMSClubName.GetCount();
                DataTable dt;
                string order = null;
                dt = CMSClubName.Getlist(from, to, order);


                if (dt != null && dt.Rows.Count > 0)
                {
                    int totalPages = (int)Math.Ceiling((double)totalRecords / 5);
                    if (cPage < totalPages)
                    {
                        lnkNext.Attributes.Add("onclick", "LisClub('" + Convert.ToInt32(cPage + 1) + "')");
                    }
                    if (cPage > 1)
                    {
                        lnkPrev.Attributes.Add("onclick", "LisClub('" + Convert.ToInt32(cPage - 1) + "')");
                    }

                    int i = 0;
                    foreach (DataRow dr in dt.Rows)
                    {
                        i++;
                        if (i == 1)
                        {
                            ltData.Text += "<div class=\"fl\"><a  href=\"javascript:void(0)\" onClick=\"showPopWinUSER('/doithamgiachitiet.aspx?ClubId=" + dr["ClubId"] + "','Chi tiet',648,500,null,null)\"><img src=\"" + dr["Avatar"].ToString() + "\" style=\"border:0px; margin-left:146px;\"/></a></div>";
                        }
                        if (i == 2)
                        {
                            ltData.Text += "<div class=\"fl\"><a  href=\"javascript:void(0)\" onClick=\"showPopWinUSER('/doithamgiachitiet.aspx?ClubId=" + dr["ClubId"] + "','Chi tiet',648,500,null,null)\"><img src=\"" + dr["Avatar"].ToString() + "\" style=\"border:0px; margin-left:44px;\"/></a></div>";
                        }
                        if (i == 3)
                        {
                            ltData.Text += "<div class=\"fl\"><a  href=\"javascript:void(0)\" onClick=\"showPopWinUSER('/doithamgiachitiet.aspx?ClubId=" + dr["ClubId"] + "','Chi tiet',648,500,null,null)\"><img src=\"" + dr["Avatar"].ToString() + "\" style=\"border:0px;\"/></a></div>";
                        }
                        if (i == 4)
                        {
                            ltData.Text += "<div class=\"fl\"><a  href=\"javascript:void(0)\" onClick=\"showPopWinUSER('/doithamgiachitiet.aspx?ClubId=" + dr["ClubId"] + "','Chi tiet',648,500,null,null)\"><img src=\"" + dr["Avatar"].ToString() + "\" style=\"border:0px; margin-left:26px;\"/></a></div>";
                        }
                        if (i == 5)
                        {
                            ltData.Text += "<div class=\"fl\"><a  href=\"javascript:void(0)\" onClick=\"showPopWinUSER('/doithamgiachitiet.aspx?ClubId=" + dr["ClubId"] + "','Chi tiet',648,500,null,null)\"><img src=\"" + dr["Avatar"].ToString() + "\" style=\"border:0px; margin-left:66px;\"/></a></div>";
                        }
                    }

                }
            }
            catch (Exception)
            {                                
            }
        }
    }
}